<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$this->model('model')->checklogin();
if($_RQ['op']=='main'){
	//注册会员
	$member=$this->get('member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$member['vipendtime1']=date('Y-m-d',$member['vipendtime']);
	$item=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','credit3','mobile','avatar','nickname'));
	$item=array_merge($item,$member);
	$item['id']=$_SESSION['uid'];
	$item['mycoupon']=pdo_count('jy_weishop_coupon_getlog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'islock'=>0,'isuse'=>0));
	$return['setting']=$return['pluginset'];
	$current_plugin=$_SESSION['current_plugin']?:'jy_lineks';
	$credit_types=credit_types();
	$return['credit3title']=$credit_types[3];
	$return['type']=0;
	$item['vipstatus']=$member['vipendtime']>time()?1:2;
	$item['viptime']=date('Y/m/d',$member['vipendtime']);
	$return['item']=$item;
	set_html('title','会员中心');
	exi($return);
}
if($_RQ['op']=='get_ti'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>'1');
	if($_RQ['keyword']){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
	}
	$ids=pdo_getall('jy_lineks_card',array('mid'=>$_SESSION['uid'],'zu_id >'=>0,'uniacid'=>$_SESSION['uniacid']),'zu_id','zu_id');
	if($ids){
		$ids=array_keys($ids);
		$params['id']=$ids;
	}else{
		$params['id']=0;
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_lineks_tiku_zu',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	if($list){
		foreach($list as &$item){
			$item['nums']=pdo_count('jy_lineks_tiku',array('uniacid'=>$_SESSION['uniacid'],'zu_id'=>$item['id']));
			$item['createtime']=date('Y-m-d H:i:s', $item['createtime']);
			$card=pdo_get('jy_lineks_card',array('mid'=>$_SESSION['uid'],'zu_id'=>$item['id']));
			if($item['liandays']){
				$isdays=(time()-$card['createtime'])/(24*3600);
				$lastliandays=intval($item['liandays']-$isdays);
				if($lastliandays>0){
					$item['lastliandays']='练习剩余：'.$lastliandays.' 天';
				}else{
					$lastliandays=abs($lastliandays);
					$item['lastliandays']='已过期：'.$lastliandays.' 天';
				}
			}
		}
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='get_ke'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>'1');
	if($_RQ['keyword']){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='get_msg'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>'1');
	if($_RQ['keyword']){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$return['list']=$list;
	exi($return);
}
?>